// ============================================================================
//  TFPawn.uc ::
// ============================================================================
class gPawn extends xPawn;

// - Aim Error ----------------------------------------------------------------

var() float                 InaccuracyXhairScaleSpeed;
var   float                 InaccuracyXhairScale;
var   float                 InaccuracyXhairScaleSmooth;

// - Hit Effects --------------------------------------------------------------

var() Range                 GibSpeed;
var() bool                  GibUseCollision;
var   bool                  bHeadGibbed;

var   int                   LastDamageAmount; // EMB - to make sure we don't gib if less than 80 dmg or so

var   float                 LastDamageTime;
var   float                 RegenPauseTime;

var   Weapon                SelectedWeapon;

var   bool                  bAcidFX;
var() float                 AcidAmbientScaling;

var   float                 LastDamageSoundTime;

var float   BloodSpawnTime;

var   gPawnAccuracy         PawnAccuracy;

// ============================================================================
// Replication
// ============================================================================
replication
{
    // Variables the server should send to the owning client.
    reliable if( bNetOwner && bNetDirty && Role == ROLE_Authority )
        LastDamageAmount, bAcidFX;
}

// ============================================================================
//  Camera
// ============================================================================

simulated function vector WeaponBob(float BobDamping)
{
    Local vector WBob;

    WBob = BobDamping * WalkBob;
    WBob.Z += LandBob;
    return WBob;
}

simulated function vector EyePosition()
{
    return EyeHeight * vect(0,0,1);
}

function CheckBob(float DeltaTime, vector Y)
{
    local float OldBobTime;
    local int m,n;
    local float Speed2D;

    OldBobTime = BobTime;

    if( bWeaponBob )
    {
        Bob = FClamp(Bob, -0.01, 0.01);
        if( Physics == PHYS_Walking )
        {
            Speed2D = VSize(Velocity);
            if( Speed2D < 10 )
                BobTime += 0.2 * DeltaTime;
            else
                BobTime += DeltaTime * (0.3 + 0.7 * Speed2D/GroundSpeed);
            WalkBob = Y * Bob * Speed2D * sin(8 * BobTime);
            AppliedBob = AppliedBob * (1 - FMin(1, 16 * deltatime));
            WalkBob.Z = AppliedBob;
            if( Speed2D > 10 )
                WalkBob.Z = WalkBob.Z + 0.75 * Bob * Speed2D * sin(16 * BobTime);
        }
        else if( Physics == PHYS_Swimming )
        {
            BobTime += DeltaTime;
            Speed2D = Sqrt(Velocity.X * Velocity.X + Velocity.Y * Velocity.Y);
            WalkBob = Y * Bob *  0.5 * Speed2D * sin(4.0 * BobTime);
            WalkBob.Z = Bob * 1.5 * Speed2D * sin(8.0 * BobTime);
        }
        else
        {
            BobTime = 0;
            WalkBob = WalkBob * (1 - FMin(1, 8 * deltatime));
        }
    }
    else
    {
        BobTime = 0;
        WalkBob = Vect(0,0,0);
        return;
    }

    if( (Physics != PHYS_Walking) || (VSize(Velocity) < 10 )
        || ((PlayerController(Controller) != None) && PlayerController(Controller).bBehindView) )
        return;

    m = int(0.5 * Pi + 9.0 * OldBobTime/Pi);
    n = int(0.5 * Pi + 9.0 * BobTime/Pi);

    if( (m != n) && !bIsCrouched )
        FootStepping(0);
    else if( !bWeaponBob && bPlayOwnFootSteps && !bIsCrouched && (Level.TimeSeconds - LastFootStepTime > 0.35) )
    {
        LastFootStepTime = Level.TimeSeconds;
        FootStepping(0);
    }
}


// ============================================================================
// DefaultProperties
// ============================================================================

defaultproperties
{
     InaccuracyXhairScaleSpeed=0.200000
     GibSpeed=(Min=700.000000,Max=1000.000000)
     GibUseCollision=True
     BloodSpawnTime=0.250000
     FootstepVolume=0.300000
     GibCountHead=1
     TransEffects(0)=Class'Taskforces.gTransportIn'
     TransEffects(1)=Class'Taskforces.gTransportIn'
     DeResTime=1.000000
     RagdollLifeSpan=999.000000
     RagDeathUpKick=0.000000
     RagImpactSoundInterval=0.150000
     TransOutEffect(0)=Class'Taskforces.gTransportOut'
     TransOutEffect(1)=Class'Taskforces.gTransportOut'
     bCanDoubleJump=False
     bCanWallDodge=False
     bAvoidLedges=True
     bCanWalkOffLedges=True
     bSpecialHUD=True
     bSpecialCrosshair=True
     WaterSpeed=300.000000
     JumpZ=424.000000
     WalkingPct=0.700000
     CrouchedPct=0.330000
     BaseEyeHeight=53.200001
     EyeHeight=53.200001
     CrouchHeight=40.599998
     CrouchRadius=35.000000
     DrivingHeight=28.000000
     DrivingRadius=30.799999
     HeadRadius=12.600000
     HeadHeight=8.400000
     WalkAnims(0)="RunF"
     WalkAnims(1)="RunB"
     WalkAnims(2)="RunL"
     WalkAnims(3)="RunR"
     LightType=LT_Steady
     LightEffect=LE_QuadraticNonIncidence
     LightHue=159
     LightSaturation=96
     LightRadius=16.000000
     DrawScale=1.400000
     AmbientGlow=0
     bShadowCast=True
     bStaticLighting=True
     CollisionRadius=35.000000
     CollisionHeight=61.599998
}
